<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.ArrayList, java.util.Iterator" %>
<%@ page import="util.Helper,pojo.ItemAttr,pojo.UserAttr" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>投票项目列表</title>
<link rel="stylesheet" href="../css/base.css" />
</head>
<body>
 <div class="wrap">
        <div class="header">
            <p class="tool_bar">
                <a href="javascript:location.reload();">[刷新]</a>
                <a href="javascript:history.go(-1);">&lt;&lt;返回上一页</a>
                <a href="../index">返回主页&gt;&gt;</a>
                <a href="../logout">[退出]</a>
            </p>
            <h1>管理菜单——投票项目信息</h1>
        </div>
        <div class="content">
            <div class="poll_items">
                <%
                   Object obj   = request.getAttribute("items");
                   if(obj == null) {
                       out.print("还没投票项目！<a href=\"./additem.jsp\">添加新项</a>");
                   } else {
                 %>
                 <form action="./poll" method="POST" name="poll_form">
                 <table cellspacing="1" cellpadding="1" border="1" width="500" align="center">
                 <tr>
                 	<td colspan="5" style="text-align: center;">投票项目列表<sub>[<a href="./additem.jsp">添加新项</a>]</sub></td>
                 </tr>
                 <tr>
                    <td width="15%">项目ID</td>
                    <td width="25%">项目名称</td>
                    <td width="15%">所得票数</td>
                    <td width="25%">创建时间</td>
                    <td>操作</td>
                 </tr>
                 <%
                       ArrayList<ItemAttr> items  = (ArrayList<ItemAttr>)obj;
                       Iterator<ItemAttr> iItems  = items.iterator();
                       while(iItems.hasNext()) {
                           ItemAttr item    = (ItemAttr)iItems.next();
                           int itemId       = item.getItemId();
                           String itemName  = item.getItemName();
                           int itemPoll     = item.getItemPoll();
                           String createTime = item.getCreateTime();
                %>
                <tr>
                    <td ><%=itemId %></td>
                    <td ><%=itemName %></td>
                    <td ><%=itemPoll %></td>
                    <td ><%=createTime %></td>
                    <td><a href="./delitem?id=<%=itemId%>">删除</a></td>
                </tr>
                <% 
                       }
                       out.print("</table>");
                   }
                %>
            </div>
        </div>
        <jsp:include page="../comm/footer.jsp" flush="true"/>
    </div>
</body>
</html>